import 'package:flutter/material.dart';

void main() {
  runApp(MaterialApp(
    home: Scaffold(
        // appBar: AppBar(
        //   title: const Text("你好111"),
        // ),
        body: myApp()),
  ));
}

class myApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return MaterialApp(
      home: Tabs()
    );
  }

}

class Tabs extends StatefulWidget{
  Tabs();
  createState()=> _TabsState();

  @override
  Widget build(BuildContext context) {
    return Text("data");
  }

  // @override
  // Widget build(BuildContext context) {
  //   // TODO: implement build
  //   throw UnimplementedError();
  // }
}

class _TabsState extends State<Tabs>{

  List pages=[
    HomePage(),
    CatePage(),
    AboutPage()
  ];
  int current_Index=0;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title:Text("tabs组件")),
      body: pages[current_Index],
      bottomNavigationBar: BottomNavigationBar(
        currentIndex: this.current_Index,//设置当前的tab索引值
        onTap: (int index) {
          setState(() {
            this.current_Index=index;
          });
        },//点击更新索引
        iconSize: 30,
        fixedColor: Colors.lightBlue,
        items: [
          BottomNavigationBarItem(
              icon: Icon(Icons.home),
              label:"首页"
          ),
          BottomNavigationBarItem(
              icon: Icon(Icons.home),
              label:"分类"
          ),
          BottomNavigationBarItem(
              icon: Icon(Icons.home),
              label: "关于"
          )

        ],
      ),
    );
  }
}

class CatePage extends StatelessWidget{
  @override
  Widget build(BuildContext context) {
    return Container(
      child: Text("这是目录页"),
    );
  }
}

class AboutPage extends StatelessWidget{
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Container(
      child: Text("这是关于页"),
    );
  }

}

class HomePage extends StatelessWidget{
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Container(
      child: Text("这是主页"),
    );
  }

}

